home *** CD-ROM | disk | FTP | other *** search
- // ⌐ 2005 The Weather Channel Interactive, Inc. All Rights Reserved.
-
- var XULSimple = null;
- var GlobalLifeStyle = null;
-
- function enableDebug() {
- Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService).notifyObservers(null, "debugupdate", null);
- window.close();
- }
-
- function loadLifestyle(){
- try{
- jsInclude("chrome://1clickweather/content/js/utils/definitions.js");
- jsInclude("chrome://1clickweather/content/js/utils/xul.js");
- jsInclude("chrome://1clickweather/content/js/utils/datadumper.js");
- jsInclude("chrome://1clickweather/content/js/utils/appconstants.js");
-
- try{
- // fire up the config system.
- // loadconfig.js can be included where ever you need access to config variables.
- // it will pop GlobalUserConfig and GlobalAppConfig into existance
- jsInclude("chrome://1clickweather/content/js/config/loadconfig.js");
- }catch(e){
- debug("lifestyle loadconfig: " + e);
- }
-
- XULSimple = new oXULSimple;
-
- GlobalLifeStyle = new oLifestyle();
- GlobalLifeStyle.Top();
- GlobalLifeStyle.Middle();
- // document.getElementById("LifeStyleWindow").setAttribute("title", "1-ClickWeather");
- }catch(e){
- debug("lifestyle init: " + e);
- }
- }
-
- // this doesn't really need to be an object but being so,
- // methods and variables are automatically scoped properly
- // so we don't step on other things
- function oLifestyle(){
-
- this.Top = function(){
- var top = document.getElementById("lifestyleTopLeft");
- var Vbox = document.createElement("vbox");
- top.appendChild(Vbox);
-
- this.drawLink(Vbox, 'homepage');
- XULSimple.Shim(Vbox, 8, 8);
- this.drawLink(Vbox, '36hour');
- XULSimple.Shim(Vbox, 8, 8);
- this.drawLink(Vbox, '10day');
-
- var top = document.getElementById("lifestyleTopRight");
- var Vbox = document.createElement("vbox");
- top.appendChild(Vbox);
-
- XULSimple.Shim(Vbox, 6, 6);
- this.drawLink(Vbox, 'desktop');
- }
-
- this.Middle = function(){
- var middle = document.getElementById("lifestyleMiddleLeft");
- var links = hash2array(GlobalUserConfig.getAllProfiles().getDefaultProfile().getLifeStyle().getLinks());
-
- // figure out how many links should show in the left hand vbox
- var maxrow = links.length / 2;
- if((maxrow * 2) < links.length){
- maxrow++;
- }
-
- var counter = 0;
- for(var i in links){
- if(counter >= maxrow){
- counter = 0;
- var middle = document.getElementById("lifestyleMiddleRight");
- }
-
- this.drawLink(middle, links[i]);
- XULSimple.Shim(middle, 8, 8);
-
- counter++;
- }
- }
-
- this.drawLink = function(box, index, args){
- var linkUrl = GlobalAppConfig.getLinkByID(index).getURL();
- linkUrl = linkUrl.replace(/LOCIDTAG/g, GlobalUserConfig.getAllProfiles().getDefaultProfile().getSetup().getLocation().getLocID());
-
- var Hbox = document.createElement("hbox");
- box.appendChild(Hbox);
-
- var icon = new oXUL.iconByID(Hbox, GlobalAppConfig.getLinkByID(index).getIcon());
- icon.onClick('GlobalLifeStyle.openLink("' + linkUrl + '");');
- icon.Make();
-
- var label = new oXUL.Label(Hbox, GlobalAppConfig.getLinkByID(index).getText());
- label.setAttribute("class", "text-link");
- label.onClick('GlobalLifeStyle.openLink("' + linkUrl + '");');
- label.Make();
- }
-
-
- this.openLink = function(url){
- if(url){
- try{
- // get ahold of the main browser window so we can load a url in it
- openLinkInNewTab(url);
- //var b = getBrowserWindow();
- //b.loadURI(url);
- // and close the lifestyle window
- window.close();
- }catch(e){
- debug("error lifestyle open link: " + e);
- }
- }
- }
- }
-
-
-
-